<include file="Public/common1" />

<block name="content">
    <div class="page-header"><h1>销售管理 &gt;订单回收站</h1></div>
    <form id="form" action="" >
        <div class="col-xs-12 clearfix">
            <div class="col-xs-3">
                <label for="" class="col-xs-4">订单号</label>
                <div class="col-xs-8"><input name="order_num" value="<if condition="$_GET['order_num']">{$_GET['order_num']}</if>" type="text" class="form-control" /></div>
            </div>
            <div class="col-xs-3">
                <label for="" class="col-xs-4">线路名称</label>
                <div class="col-xs-8"><input name="line_name" type="text" value="<if condition="$_GET['line_name']">{$_GET['line_name']|urldecode = ###}</if>" class="form-control" /></div>
            </div>
            <div class="col-xs-3">
                <label for="" class="col-xs-4">出发城市</label>
                <div class="col-xs-8"><input name="set_out" type="text" value="<if condition="$_GET['set_out']">{$_GET['set_out'] |urldecode = ### }</if>" class="form-control" class="form-control" /></div>
            </div>

        </div>

        <div class="col-xs-12 clearfix mt-15">

            <div class="col-xs-3">
                <label for="" class="col-xs-4">游客姓名</label>
                <div class="col-xs-8"><input  name="tourists_name" type="text" value="<if condition="$_GET['tourists_name']">{$_GET['tourists_name'] |urldecode = ###}</if>" class="form-control" class="form-control" /></div>
            </div>

            <div class="col-xs-3">
                <label for="" class="col-xs-4">联系方式</label>
                <div class="col-xs-8"><input type="text" name="tourists_phone"  value="<if condition="$_GET['tourists_phone']">{$_GET['tourists_phone']}</if>" class="form-control" class="form-control" /></div>
            </div>

            <div class="col-xs-3">
                <label for="" class="col-xs-4">销售人</label>
                <div class="col-xs-8">
                    <select name="sales_id">
                        <option value="">全部</option>
                        <foreach name="staff" item="v">
                            <option value="{$v['reseller_id']}" <if condition="$v['reseller_id'] == $_GET['sales_id']">selected</if>>{$v['reseller_name']}</option>
                        </foreach>
                    </select>
                </div>
            </div>
        </div>

        <div class="col-xs-12 clearfix mt-15">
            <label for="" class="col-xs-1">下单时间</label>
            <div class="col-xs-2"><input name="start_time" placeholder="开始时间" id="start" value="<if condition="$_GET['start_time']">{$_GET['start_time'] |urldecode = ###}</if>" class="form-control" class="form-control" /></div>
            <div class="col-xs-2"><input name="end_time" placeholder="结束时间" id="end" value="<if condition="$_GET['end_time']">{$_GET['end_time'] |urldecode = ###}</if>" class="form-control" class="form-control" /></div>
        </div>
        <div class="col-xs-12 clearfix mt-15">
            <button type="button" id="export" class="btn btn-primary" style="margin-right: 10px">导出</button>
            <button class="btn btn-primary">查询</button>
        </div>
    </form>

    <table class="table table-striped  table-bordered table-hover table-condensed  mt-15">
        <thead>
            <tr>
                <th>订单号</th>
                <th>线路名称</th>
                <th>団号</th>
                <th>游客姓名</th>
                <th>联系方式</th>
                <th>预定人数</th>
                <th>销售单价</th>
                <th>出发城市</th>
                <th>下单时间</th>
                <th>销售人</th>
                <th>状态</th>
                <th>负责人</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <foreach name="orderList['list']" item="v">
            <tr>
                <td>{$v['order_num']}</td>
                <td>{$v['line_name']}</td>
                <td>{$v['group_num']}</td>
                <td>{$v['tourists_name']}</td>
                <td>{$v['tourists_phone']}</td>
                <td>
                    预订人数：{$v['total_num']}<br/>
                    大：{$v['adult_num']}<br/>
                    小：{$v['child_num']}<br/>
                    老：{$v['oldMan_num']}
                </td>
                <td>大：{$v['adult_price']}<br/>
                    小：{$v['child_price']}<br/>
                    老：{$v['oldman_price']}
                </td>

                <td>{$v['set_out']}</td>
                <td>{$v['create_time']}</td>
                <td>{$v['sales']}</td>
                <td>{$v['html']}</td>
                <td>{$v['manager']}</td>
                <td>
                    <button class="btn btn-primary" onclick="openDetail({$v['order_id']})">详情</button>
                </td>
            </tr>
            </foreach>
        </tbody>
    </table>
    <ul class="pagination pull-right">{$orderList['show']}</ul>
</block>
<block name="js">
<script src="__JS__/jedate/jedate.js"></script>
<script>
$form = $('#form');
//导出excel
$('#export').click(function(){
    $form.attr('action', '{:U('orderRecoveryExportExcels')}');
    $form.submit();
    $form.attr('action', '');
})

dateFormat($('#start'), 'YYYY-MM-DD');
dateFormat($('#end'), 'YYYY-MM-DD');

/**
 * 绑定日期选择器
 * @param  {[obj]}    obj        [元素]
 * @param  {[string]} dateFormat [时间格式]
 */
function dateFormat(obj, dateFormat){
    jeDate({
        dateCell: '#'+$(obj).attr('id'),
        format: dateFormat,
        isinitVal:false,
        isTime:true, //isClear:false,
        okfun:function(val){
        }
    });
}

/**
 * 打开订单详情页面
 * @param  {[int]}    orderId     [订单id]
 */
function openDetail(oId){
    layer.open({
        type: 2,
        area: ['90%','80%'],
        title: '订单详情',
        content: '/Reseller/Index/orderDetail/order_id/'+oId,
    })
}


</script>
</block>
